
/**		
 * 
 *	uk.co.lmfm.guppy.view.AlertMediator
 *	
 *	@version 1.00 | Feb 2, 2010
 *	@author Justin Windle
 *  
 **/
 
package uk.co.lmfm.guppy.view 
{
	import uk.co.lmfm.guppy.model.vo.AlertVO;
	import uk.co.lmfm.guppy.application.enum.ApplicationConstants;
	import uk.co.lmfm.guppy.view.components.alert.AlertView;

	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.interfaces.IMediator;
	import org.puremvc.as3.multicore.patterns.mediator.Mediator;

	/**
	 * AlertMediator
	 */
	public class AlertMediator extends Mediator implements IMediator 
	{
		//	----------------------------------------------------------------
		//	CONSTANTS
		//	----------------------------------------------------------------

		public static const NAME : String = "AlertMediator";

		//	----------------------------------------------------------------
		//	CONSTRUCTOR
		//	----------------------------------------------------------------

		public function AlertMediator(viewComponent : AlertView = null)
		{
			super(NAME, viewComponent);
		}

		//	----------------------------------------------------------------
		//	PUBLIC METHODS
		//	----------------------------------------------------------------

		override public function onRegister() : void
		{
			super.onRegister();
		}

		override public function listNotificationInterests() : Array
		{
			return [ApplicationConstants.SHOW_ALERT];
		}

		override public function handleNotification(notification : INotification) : void
		{
			super.handleNotification(notification);
			
			var name : String = notification.getName();
			var body : Object = notification.getBody();
			
			switch(name)
			{
				case ApplicationConstants.SHOW_ALERT : 
				
					component.showAlert(body as AlertVO);
				
					break;
			}
		}

		//	----------------------------------------------------------------
		//	PUBLIC ACCESSORS
		//	----------------------------------------------------------------

		public function get component() : AlertView
		{
			return viewComponent as AlertView;
		}
	}
}
